home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 31
/
Aminet 31 (1999)(Schatztruhe)[!][Jun 1999].iso
/
Aminet
/
dev
/
basic
/
NewCommandSet.lha
/
NewCommandSet_V1.80
/
Tools
/
NewFDConvert
/
newfdconvert.asc
< prev
next >
Wrap
Text File
|
1999-03-27
|
8KB
|
366 lines
; fdconvert.bb2 with added file requesters!
; Right, now create Resource fixed
; Now the program presents you the best library ID !!!
; And now the executable don' t suxx if the library isn' t available...
v$="$VER: NewFDConvert v1.0 (5-11-1998) ACID/JLB"
WBStartup
NoCli
FindScreen 0
MaxLen p$=180:MaxLen f$=180:MaxLen lib$=180
p$="RAM:":lib$="LIBS:"
*SC.Screen=Peek.l(Addr Screen(0)) ; get a pointer to screen
*SCFONT.TextAttr=*SC.Screen\Font ; and to the screen's font
HEIGHT_WBFONT.b=(*SCFONT.TextAttr\ta_YSize) ; get font height
fname$=Peek$(*SCFONT.TextAttr\ta_Name); and font name
LoadFont 0,fname$,HEIGHT_WBFONT ; load font name,font height
ww.w=400 ; width of window
wh.w=100 ; height of window
wx.w=ScreenWidth/2-ww/2 ; centre...
wy.w=ScreenHeight/2-wh/2 ; ...window
If Window (0,wx,wy,ww,wh,$20140e,"NewFDConvert",1,2)=0
Request "NewFDConvert","Failed to open window!","END"
End ; quit if window can't open
EndIf
NPrint " NewFDConvert by James L Boyd, based on :"
WPrintScroll
NPrint " FDConv V ?.? - Written by Mark Sibly"
WPrintScroll
NPrint " V2.0 updated by Andre Bergmann"+Chr$(10)
WPrintScroll
NPrint ""
WPrintScroll
DEFTYPE.l
;
;fdinfo prog... suss out an fd file, and return library offsets!
;
Statement align{}
;
SHARED co$
;
l.q=Len(co$)
If l/2<>Int(l/2) Then co$+Chr$(0)
;
End Statement
Statement fillin{src.l} ;src=source to change
;
SHARED co$
;
co$=Left$(co$,src)+Mkl$(Len(co$))+Mid$(co$,src+5)
;
End Statement
Statement dir{}
SHARED bestlibnr.w
bestlibnr.w=255
libnr.w=0
dev$="BlitzLibs:AmigaLibs/"
lock.l=Lock_(&dev$,-2)
If lock
infoadr.l=AllocMem_(260,0)
If infoadr
ok=Examine_(lock,infoadr)
Repeat
ok=ExNext_(lock,infoadr)
If ok AND Peek.l(infoadr+4)=-3 AND Instr(UCase$(Peek$(infoadr+8)),".INFO")=0
rfile$=dev$+Peek$(infoadr+8)
fh.l=Open_(&rfile$,1005)
If fh
Seek_ fh,36,#OFFSET_CURRENT ;36 & 86
Read_ fh,&libnr,2
If libnr<bestlibnr
bestlibnr=libnr
EndIf
Close_ fh
EndIf
EndIf
Until ok=0
FreeMem_ infoadr,260
EndIf
UnLock_(lock)
bestlibnr-1
Else
NPrint "Sorry, not able to get device lock..."
WPrintScroll
EndIf
End Statement
fd$=ASLFileRequest$("Select .fd file",p$,f$,"#?.fd")
If fd$="" OR f$="" Then End
f$=""
dest$="blitzlibs:amigalibs/"
Dim n$(1000),h$(1000),p$(1000),o.w(1000)
Dim l$(10),ln(10) ;max libs split-up
If ReadFile(0,fd$)
NPrint "Examining FD File..."
WPrintScroll
FileInput 0:Gosub sussfd:CloseFile 0:DefaultInput
;
;ok... fd file sussed - now to make output file...
;
Gosub makelib
;
Else
NPrint "Couldn't open file for reading."
WPrintScroll
End
EndIf
End
.makelib ;n=number of commands...
here0
ll.l=OldOpenLibrary_(&li$)
If ll
CloseLibrary_ ll:islib=-1
Else
ll.l=OpenResource_(&li$)
If ll
islib=0
Else
li$=ASLFileRequest$("Library name",lib$,f$,"#?.library")
li$=f$
If li$="" Then Return
Goto here0
EndIf
EndIf
;
;li$=library name! - generate amigalibs name
;
nl=(n-1)/127+1 ;how many libs to make
NPrint "Library will require ",nl," Amigalibs files..."
WPrintScroll
For k=1 To nl
fh.l=Open_(dest$+li$+Str$(1),#MODE_OLDFILE)
If fh
Seek_ fh,36,#OFFSET_CURRENT ;36 & 86
Read_ fh,&libnr.w,2
Close_ fh
Request "NewFDConvert","Library already exists! Library ID: "+Str$(libnr),"Oh...":End
WPrintScroll
Else
dir{}
EndIf
here
r$="Use dev/basic/blitzman to find free library numbers..."
r$+Chr$(10)+"Enter new library number (1-255 or 0 to abort) :"
ln(k)=RTEZGetLongRange("NewFDConvert",r$,0,255,bestlibnr)
WPrintScroll
If ln(k)=0
End
EndIf
If ln(k)>255 OR ln(k)<1
NPrint "Illegal library ID":Goto here
WPrintScroll
EndIf
Next
ln=ln(1)
;
li2$=li$
clearup:k=Instr(li2$,":"):If k Then li2$=Mid$(li2$,k+1):Goto clearup
clearup2:k=Instr(li2$,"/"):If k Then li2$=Mid$(li2$,k+1):Goto clearup
;
nn=127:li=0
;
For tk=1 To n
;
nn+1
If nn=128
;
If li Then Gosub libdone
;
li+1
If WriteFile(0,dest$+li2$+Str$(li))=0
NPrint "Error creating File : ",li$+Str$(li)
WPrintScroll
Pop For:Return
EndIf
;
co$=Mkl$(0)+Mki$(ln(li))+String$(Chr$(0),20)
If li=1 Then co$+Mki$(1) Else co$+Mki$(0)
co$+String$(Chr$(0),20)
nn=1:NPrint "-------------------- NEW LIB -----------------------"
WPrintScroll
;
EndIf
;
NPrint "CREATING : ",n$(tk),"_",suf$," ",h$(tk)," ",p$(tk)
WPrintScroll
co$+Mki$(6)+Mkl$(0)+Mki$(ln(1))+Mki$(o(tk)) ;type and link
;
p$=Mid$(p$(tk),2)
While Left$(p$,1)="a" OR Left$(p$,1)="d"
If Left$(p$,1)="a"
co$+Chr$(Val(Mid$(p$,2,1))+16)
Else
co$+Chr$(Val(Mid$(p$,2,1)))
EndIf
p$=Mid$(p$,4)
Wend
;
co$+Chr$(-1)
align{}
co$+Mkl$(0)+Mki$(0)+n$(tk)+"_"+suf$+Chr$(0)+h$(tk)+Chr$(0)
align{}
;
Next
;
If co$ Then Gosub libdone
;
Return
.libdone
;
If li=1 ;first one - create 'openlibrary' stuff!
;
;make 'init' nullsub!
;
fillin{$16}
co$+String$(Chr$(0),12):iat=Len(co$)
co$+Mkl$(0)+Mkl$(0)
;
;make 'finit' nullsub!
;
fillin{$1c}
co$+String$(Chr$(0),6)+Mki$(ln(1))+Mki$($1100)+Mki$(0)
co$+Mkl$(0):fat=Len(co$)
co$+Mkl$(0)+Mkl$(0)
;
co$+Mki$(-1)+Mkl$(0)
;
;make 'libinit' code!
;
fillin{iat}
co$+Mkl$($2c780004) ; move.l 4.w,a6
If islib
co$+Mkl$($43fa0022) ;loop lea libname(pc),a1
Else
co$+Mkl$($43fa001d)
EndIf
co$+Mki$($7000) ; moveq #0,d0
co$+Mki$($4eae)
If islib
co$+Mki$(-552) ; jsr openlibrary(a6)
Else
co$+Mki$(-498) ; jsr openresource(a6)
EndIf
; co$+Mki$($4a80) ; tst.l d0
; co$+Mkl$($6700fff4) ; beq loop
co$+Mki$($4e75) ; rts
;
;make 'libfinit' code!
;
fillin{fat}
If islib
; co$+Mkl$($2c780004) ; move.l 4.w,a6
; co$+Mkl$($4eeefe62) ; jmp -$19e(a6)
; Well, the fellowing code should create something like this:
; MOVE.l a1,d0
; TST.l d0
; BEQ skip
; MOVEA.l 4,a6
; JSR -$19e(a6)
; skip:
; RTS
co$+Mkl$($20094A80)
co$+Mkl$($6700000C)
co$+Mkl$($2C790000)
co$+Mkl$($00044EAE)
co$+Mkl$($FE624E75)
co$+Mkl$($70004E75)
Else
co$+Mki$($4e75)
EndIf
;
;add 'name.library'
;
co$+li$+Chr$(0)
;
;All Code Done! - now for reloc stuff
;
re$=Mkl$($3ec)+Mkl$(4)+Mkl$(0)+Mkl$($16)+Mkl$($1c)
re$+Mkl$(iat)+Mkl$(fat)+Mkl$(0)
;
Else
;
co$+Mki$(-1)+Mkl$(0)
;
EndIf
;
While (Len(co$) AND 3)
co$+Chr$(0)
Wend
;
;Now for header stuff
;
cl=Len(co$)/4
;
in$=Mkl$($3f3)+Mkl$(0)+Mkl$(1)+Mkl$(0)+Mkl$(0)
in$+Mkl$(cl)+Mkl$($3e9)+Mkl$(cl)
;
FileOutput 0
Print in$,co$,re$,Mkl$($3f2)
CloseFile 0:DefaultOutput
;
co$="":re$="":Return
.sussfd
n=0:bi=-30:li$="":gen=-1
While NOT Eof(0)
l$=Edit$(256)
If Left$(l$,1)<>"*"
If Left$(l$,2)="##"
c$=LCase$(Mid$(l$,3)):c$=StripLead$(c$,32)
If Left$(c$,6)="public" Then gen=-1
If Left$(c$,7)="private" Then gen=0
If Left$(c$,3)="end" Then Return
If Left$(c$,4)="bias" Then bi=-Val(Mid$(c$,5))
Else
If gen
b1=Instr(l$,"(") ;first bracket
b2=Instr(l$,"(",b1+1) ;second bracket
If b1>0 AND b2>0
n+1
o(n)=bi
n$(n)=Left$(l$,b1-1)
h$(n)=Mid$(l$,b1,b2-b1):If h$(n)="()" Then h$(n)=""
p$(n)=LCase$(Mid$(l$,b2))
Else
NPrint "Error in file :"
WPrintScroll
NPrint l$
WPrintScroll
EndIf
EndIf
bi-6
;
EndIf
Else
n$=Mid$(l$,2):n$=StripLead$(n$,32)
If Left$(n$,1)=Chr$(34)
n2=Instr(n$,Chr$(34),2)-2
If n2>0
li$=Mid$(n$,2,n2)
EndIf
EndIf
EndIf
Wend
Return